package dale.web.core.filter;

import dale.web.core.log.HttpLogger;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LogFilter implements Filter {

	private static final Log log = LogFactory.getLog(LogFilter.class);
	
    public LogFilter() {
    }

    public void init(FilterConfig filterconfig) throws ServletException {
    }

    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest req = (HttpServletRequest)request;
        HttpServletResponse res = (HttpServletResponse)response;
        HttpLogger logger = new HttpLogger(req, res);
        logger.logBefore(log);
        chain.doFilter(request, response);
        // logger.logAfter(log);
    }

    public void destroy() {
    }

}
